<?php
/**
 * Autoloader below is a quick way to just make this example run. On production code, it would be at another place 
 */
function __autoload($class_name) {
    include $class_name.'.php';
}

/**
 * Some sample requirements for this exercise:
 * 1. List contents, given a folder path
 * 2. Demonstrate usage of Interfaces & design patterns as appropriate
 * 3. A sample Unit Test
 * 
 * A sample folder is given below which can be modified based on OS
 * The heirarchy for the file & folder classes is as follows:
 * FileInterface --> FileAbstract 	--> FileItem	--> PictureFileItem
 * 													--> MediaFileItem
 * 													--> DocumentFileItem     (and so on for specific special file types)
 * 									--> FolderItem
 * A simple reasoning for the above scheme would be, as on an OS a file & folder are basically look the the same to the FileSystem. 
 * A folder is treated as a special file by the OS. The most common operations for files & folders are the same(move, copy, delete, rename etc.).
 * Files & folders also have common properties associated with them(name, filesize, read, write & sharing permissions).
 * For specific file type properties we can extend the base FileItem class(if so desired per requirement)
 * For generation of file/folder objects 'Factory' pattern is used
 */
$folder = 'c:\xampp';	//example of given folder

//get contents & print individual file/folder info
$lf = new LocalFileOperations();
foreach($lf->listContents($folder) as $item)
{		
	$info = $item->getInfo();
	if($item->isDir())
		echo "FOLDER\t";
	else
		echo "FILE\t";
	echo $info['name']."\n";
}

?>